package com.hc;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.util.Date;
import java.util.List;

public class People {
    private Integer id;
    @JsonProperty("user") //将字段的属性名修改后返回
    private String username;
    @JsonIgnore //过滤字段,不返回
    private String password;
    @JsonFormat(pattern = "yyyy-MM-dd") //时间格式化再返回
    private Date birth;
    @JsonInclude(JsonInclude.Include.NON_NULL) //不为空时再返回
    private String nickname;
    @JsonInclude(JsonInclude.Include.NON_EMPTY) //不为空且长度不为0等有意义时再返回
    private List<String> hobby;
    @JsonSerialize(using = DoubleSerialize.class) //按照自定义规则生成属性信息
    private Double salary;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public List<String> getHobby() {
        return hobby;
    }

    public void setHobby(List<String> hobby) {
        this.hobby = hobby;
    }

    public Double getSalary() {
        return salary;
    }

    public void setSalary(Double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "People{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", birth=" + birth +
                ", nickname='" + nickname + '\'' +
                ", hobby=" + hobby +
                ", salary=" + salary +
                '}';
    }
}
